Skip to content

fix(loop): reset a unit left in_progress by a killed run instead of halting - #3606

Merged
clabonte merged 2 commits into
mainfrom
fix/issue-3602-reset-interrupted-unit
Nov 26, 2026
Merged

clabonte merged 2 commits into
mainfrom
fix/issue-3602-reset-interrupted-unit

Conversation

@clabonte

Copy link
Copy Markdown
Contributor

Closes #3602.

Root cause

A unit is in_progress only while a driver is running it. A driver killed mid-attempt never moves it to an outcome, so the next specfuse run found it neither dispatchable nor finished and halted the gate with "never became ready", telling the operator to reset the frontmatter by hand.

Fix

run() already holds the working tree's .specfuse/.loop.lock before it loads the gate's units, so no other driver in this tree can be running such a unit. On a real run, the new reset_interrupted_units returns each in_progress unit to pending with attempts: 0, the reset is committed as bookkeeping (so a later failed attempt's git reset --hard cannot restore the stale status), and the unit is dispatched. The killed attempt does not count against the unit: a fresh dispatch is numbered from 1. --dry-run writes nothing; its halt text now says a real run resets the unit. blocked_human is untouched.

No new event type: the reset is recorded by its bookkeeping commit and a console line.

Tests

tests/test_interrupted_unit_reset.py drives a real loop.run() on a temp git repo with the agent session stubbed:

  • the interrupted unit is reset, dispatched, and reaches done with attempts: 1; the unit behind it runs too; the reset is committed;
  • --dry-run leaves the file unchanged and dispatches nothing;
  • control: a blocked_human unit is not reset.

The first test fails on main with the exact halt from the report.

Verification

scripts/smoke-test.sh: 5104 tests OK (4 skipped); lint, security and coverage green.

🤖 Generated with Claude Code

Test and others added 2 commits November 25, 2026 18:22
…alting

Closes #3602. A unit is `in_progress` only while a driver runs it; a driver
killed mid-attempt never moves it to an outcome, so the next `specfuse run`
found it neither dispatchable nor finished and halted the gate with "never
became ready", asking the operator to edit its frontmatter by hand.

`run()` now holds the working tree's `.specfuse/.loop.lock` before it loads the
gate's units, so no other driver in this tree can be running such a unit. On a
real (non-dry) run, `reset_interrupted_units` returns each `in_progress` unit
to `pending` with `attempts: 0`, the reset is committed as bookkeeping (so a
later failed attempt's `git reset --hard` cannot restore the stale status),
and the unit is dispatched. The killed attempt does not count: the attempt
loop numbers a fresh dispatch from 1. `--dry-run` writes nothing and still
reports the unit, with wording that now says a real run will reset it.
`blocked_human` is untouched.

Tests:
- tests/test_interrupted_unit_reset.py: a real `loop.run()` on a temp repo
  resets and dispatches the interrupted unit and the one behind it (attempts
  recorded as 1, reset committed); dry-run writes nothing; a blocked_human
  unit is left for the operator (control).

Verification:
- scripts/smoke-test.sh: 5104 tests OK (4 skipped), lint/security/coverage green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clabonte
clabonte merged commit 3bc8bef into main Nov 26, 2026
6 checks passed
@clabonte
clabonte deleted the fix/issue-3602-reset-interrupted-unit branch November 26, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A work unit left in_progress by a killed run blocks the next run until it is reset by hand

1 participant